package com.tuling.consumer;

import com.tuling.DemoService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.IOException;

/*
* https://cn.dubbo.apache.org/zh-cn/docsv2.7/user/examples/local-stub/
* */
@EnableAutoConfiguration
public class StubDubboConsumerDemo { /* 消费端服务降级 - 本地存根 */


//    @Reference(version = "timeout", timeout = 1000, stub = "com.tuling.DemoServiceStub")
    @Reference(version = "timeout", timeout = 1000, stub = "true") /* 默认找com.tuling.DemoService+Stub */
    private DemoService demoService;//默认注入的是com.tuling.DemoServiceStub 类

    public static void main(String[] args) throws IOException {
        ConfigurableApplicationContext context = SpringApplication.run(StubDubboConsumerDemo.class);

        DemoService demoService = context.getBean(DemoService.class);

        System.out.println((demoService.sayHello("周瑜")));


    }

}
